import sqlite3
from openpyxl import load_workbook

conn = sqlite3.connect('./test.db')
wb = load_workbook("豆瓣电影总.xlsx")
ws = wb["Sheet1"]

try:
    curs = conn.cursor()

    query = "INSERT INTO xs VALUES(?,?,?,?,?,?,?,?,?,?)"
    for i in range(2, ws.max_row):
        tx = []
        for j in ws[i]:
            tx.append(j.value)
        curs.execute(query, tx)

    curs.close()
    conn.commit()
except Exception as e:
    print("operation error!")
finally:
    conn.close()
